#pragma once
#include "RequestQueue.h"
#include <math.h>

class Client
{
public:
    Client(RequestQueue* requestQueue, std::string name, long seed)
        : requestQueue(requestQueue), name(name), seed(seed)
    {
    }

public:
    std::string getName()
    {
        return name;
    }
    long getSeed()
    {
        return seed;
    }
    RequestQueue* getRequestQueue()
    {
        return requestQueue;
    }

private:
    RequestQueue* requestQueue;
    std::string   name;
    long          seed;
};

class ClientThread
{
public:
    static unsigned __stdcall run(void* p)
    {   
        Client* client = (Client*)p;
        char buf[16];
        srand(client->getSeed());

        for(int i = 0; i < 10000; i++)
        {
            sprintf(buf, "No. %d", i);
            Request* r = new Request(buf);
            client->getRequestQueue()->putRequest(r);
            std::string s(client->getName() + " requests  " + r->toString());
            printf("%s\n", s.c_str());
            Sleep(rand()%1000);
        }       

        return 0;
    }
};